package com.kws.merchant.util;

import com.kws.common.config.constant.MinioCommonBucket;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

/**
 * @author :yxy
 * @date : 2024/11/27
 */
@Component
public class FileUtil {

    private static String minioUrl;

    @Autowired
    public FileUtil(@Value("${minio.ENDPOINT}")String minioUrl) {
        FileUtil.minioUrl = minioUrl;
    }


    public static String subFileName(String fileName){
        if (fileName==null){
            return "";
        }
        return fileName.replaceAll(fixFileName(), "");
    }

    /**
     * minio前缀
     * @return
     */
    public static String fixFileName(){
        return minioUrl + "/" + MinioCommonBucket.HUATAI_PUB_BUCKET + "/";
    }
}
